<template>
  <div class="recentQuestion t-25">
    <div class="t-10 f-l">常见问题</div>

    <el-divider />
    <div v-for="item in faq" :key="item.id" class="items">
      <div class="p-5">
        <el-link
          @click="toDetails(item.id, item.category)"
          target="_blank"
          class="one"
          >{{ item.title }}</el-link
        >
      </div>
    </div>
  </div>
</template>
  <script>
import { $getRecentFaq } from "../api/faq";
export default {
  data() {
    return {
      faq: {
        id: "",
        title: "",
        category: "",
      },
    };
  },
  mounted() {
    this.loadData();
  },
  methods: {
    async loadData() {
      let { data } = await $getRecentFaq();
      this.faq = data;
    },
    toDetails(id, category) {
      let url = this.$router.resolve({
        path: "/detail",
        query: { id: id, category: category },
      });
      window.open(url.href, "_blank");
      // this.$router.push({
      //   path: "/detail",
      //   query: { category: category, id: id },
      // });
    },
  },
};
</script>
  
  <style>
.recentQuestion {
  width: 300px;
  background-color: #ffffff;
  text-align: left;
  padding: 20px;
}

.m-t-10 {
  margin-top: 10px;
}
.m-b-10 {
  margin-bottom: 10px;
}
.t-a-l {
  text-align: left;
}
.fw-b {
  font-weight: bold;
}
.p-5 {
  padding: 5px 0;
}
.items :hover {
  background-color: #eaeef1;
}
.one {
  display: inline-block;
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.el-link__inner {
  display: inline-block;
  white-space: nowrap;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
</style>